package com.kakarote.oa.controller;


import cn.hutool.core.bean.BeanUtil;
import com.kakarote.core.common.Result;
import com.kakarote.core.entity.BasePage;
import com.kakarote.core.feign.oa.entity.OaExamine;
import com.kakarote.core.feign.oa.entity.OaExamineVO;
import com.kakarote.oa.entity.BO.AuditExamineBO;
import com.kakarote.oa.entity.BO.ExamineDraftPageBO;
import com.kakarote.oa.entity.BO.OaSearchBO;
import com.kakarote.oa.entity.VO.ExamineVO;
import com.kakarote.oa.service.IOaSuperExamineService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: 超级审批
 * @company: 卡卡罗特软件科技有限公司
 * @author: zyh
 * @date: 2022/8/27 11:16
 * @version: @Version: V1.0
 */
@RestController
@RequestMapping("/oaSuperExamine")
@Slf4j
public class OaSuperExamineController {

    @Autowired
    private IOaSuperExamineService oaSuperExamineService;

    /**
     * 功能描述: <br>
     * 〈获取抄送给我列表数据〉
     *
     * @param:
     * @return: com.kakarote.core.common.Result<java.util.List < java.util.Map < java.lang.String, java.lang.Object>>>
     * @throws:
     * @author: zyh
     * @date: 2022/8/27 11:19s
     */
    @ApiOperation("草稿")
    @PostMapping(value = "/draft")
    public Result<BasePage<ExamineVO>> selectDraftOaEaminePage(@RequestBody ExamineDraftPageBO searchBO) {
        return Result.ok(oaSuperExamineService.selectDraftOaEaminePage(searchBO));
    }

    ;

    /**
     * 功能描述: <br>
     * 首页搜索根据审批是由查询审批列表
     *
     * @param content
     * @return
     */
    @ApiOperation("首页-审批搜索")
    @PostMapping(value = "/queryExamineByName")
    public Result<List<OaExamine>> queryExamineByName(@RequestParam String content) {
        return Result.ok(oaSuperExamineService.queryExamineByName(content));
    }

    ;

    //------------------------------------------
    @ApiOperation("首页-审批搜索")
    @PostMapping(value = "/queryExamineByNameForPage")
    public Result<BasePage<OaExamine>> queryExamineByNameForPage(@RequestBody com.kakarote.core.feign.oa.entity.OaSearchBO oaSearchBO) {
        OaSearchBO itemSearchBO = new OaSearchBO();
        BeanUtil.copyProperties(oaSearchBO, itemSearchBO);
        return Result.ok(oaSuperExamineService.queryExamineByNameForPage(itemSearchBO));
    }


    /**
     * 功能描述: <br>
     * 〈〉
     *
     * @param: examineId
     * @return: com.kakarote.core.common.Result<com.kakarote.core.feign.oa.entity.OaExamineVO>
     * @throws:
     * @author: zyh
     * @date: 2022/8/27 11:19s
     */
    @ApiOperation("待办-审批详情")
    @PostMapping(value = "/examine/info/{examineId}")
    public Result<OaExamineVO> getExamineInfo(@PathVariable("examineId") Long examineId) {
        return Result.ok(oaSuperExamineService.getExamineInfo(examineId));
    }

    ;

    @ApiOperation("跟踪-审批操作--归档")
    @PostMapping(value = "/actionExamine")
    public Result actionExamine(@RequestBody AuditExamineBO auditExamineBO) {
        oaSuperExamineService.actionExamine(auditExamineBO);
        return Result.ok();
    }
}

